Receives data from a opened socket
UDPRecv ( socketarray, maxlen )
Parameters
socketarray | The socket/array as returned by a UDPBind function. |
maxlen | max # of characters to receive |
Return Value
Success: | Returns binary/string sent by the opened socket. |
Failure: | Returns "" and set @error according to WSAGetError Windows API return. |
Remarks
If binary data is received it can be converted to a hexadecimal string with the String function.
Related
UDPBind, UDPOpen, String
Example
;;This is the UDP Server
;;Start this first
; Start The UDP Services
;==============================================
UDPStartup()
; Bind to a SOCKET
;==============================================
$socket = UDPBind("127.0.0.1", 65532)
If @error <> 0 Then Exit
While 1
$data = UDPRecv($socket, 50)
If $data <> "" Then
MsgBox(0, "UDP DATA", $data, 1)
EndIf
sleep(100)
WEnd
Func OnAutoItExit()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc